package com.rd.student.jiaji.class2.duyukun.Day0728;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.ArrayList;

public class Test2 {
    public static void main(String[] args) throws Exception {
        testRead();
    }

    public static void testRead() throws Exception {
        File file = new File("all.txt");
        InputStream is = new FileInputStream("all.txt");
        int cnt = 0;

        while (true){
            byte[] arr = new byte[1024];
            int len = is.read(arr);
            if (len == -1) {
                System.out.println();
                System.out.println(cnt);
                System.out.println("读取成功");
                break;
            }
            String content = new String(arr);
            System.out.println(content);
            ArrayList arrayList = new ArrayList();
            arrayList.add(len + "--" + content);

            cnt++;
        }
        is.close();
    }
}
